package edu.xmut.yuepai.common.utils;

import com.alibaba.fastjson.JSON;
import edu.xmut.yuepai.common.result.R;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class ServletUtils {
    public static void sendJson(R r, HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json");
        try {
            String jsonString = JSON.toJSONString(r);
            response.getWriter().write(jsonString);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
